<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/common/common.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<c:set var="mb" value="on"/>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<script type="text/javascript" src="${base}/js/html5shiv-printshiv.js"></script>
		<title>${siteName}</title>
		<%@ include file="/common/commonstyle.jsp" %>
		<link rel="stylesheet" type="text/css" href="${base}/css/spinner.css" />
		<script type="text/javascript" src="${base}/js/jquery.spinner.js"></script>
		<script type="text/javascript">
			function toShopCar(userId) {
				if("" == userId || "undefined" == typeof(userId)) {
					loginModel()
				} else {
					location.href='${base}/orderFrontCtl/orderinfo'
				}
			}
			
 			function addShopCar(comboId) {
 				var comboCount = $("#comboCount" + comboId).val();
 				if(0 >= comboCount) {
					jAlert("<spring:message code='warescounterror' />", "温馨提示");
 				} else {
 					location.href="${base}/orderFrontCtl/toBusinessOrder";
//					$.ajax({
//						url : "${base}/orderFrontCtl/addShopCar",
//						type : "post",
//						data:{
//							waresId : comboId,
//							waresCount : comboCount,
//							waresType : 2
//						},
//						success: function (result) {
//							var resultArray = result.split(",");
//							jAlert("购物车共有" + resultArray[0] + "件商品，合计：￥" + resultArray[1] + "温馨提示");
//						}
//					});
 				}
 			}
			
			$(function() {
				$("#loginForm").submit(function(){
					var email = $("#email").val();
					var password = $("#password").val();
					if(null == email || "" == email) {
						jAlert("<spring:message code='loginempty' />");
						return false;
					} else if(null == password || "" == password) {
						jAlert("<spring:message code='loginempty' />");
						return false;
					} else {
						return true;
					}
				});
				
				$(".numberspinner[name=combo]").numberspinner({
					name: "comboCount",
					value: 0,
					onValueChanged: function(waresId, waresCount) {
						var changeCount = waresCount - $("#waresCcount" + waresId).val();
						var totalPrice = parseFloat($("#dishTotalPrice").html()) * 10;
						var changePirce = parseFloat($("#waresPirce" + waresId).val()) * changeCount * 10;
						totalPrice = (totalPrice  + changePirce) / 10;
						$("#dishTotalPrice").html(totalPrice);
						$("#waresCcount" + waresId).val(waresCount);
					}
				});
				
				$(".numberspinner[name=dish]").numberspinner({
					name: "wareCount",
					value: 0,
					onValueChanged: function(waresId, waresCount) {
						var changeCount = waresCount - $("#waresCcount" + waresId).val();
						var totalPrice = parseFloat($("#dishTotalPrice").html()) * 10;
						var changePirce = parseFloat($("#waresPirce" + waresId).val()) * changeCount * 10;
						totalPrice = (totalPrice  + changePirce) / 10;
						$("#dishTotalPrice").html(totalPrice);
						$("#waresCcount" + waresId).val(waresCount);
					}
				});
				
				$("#addShopCarBtn").bind("click", function() {
					var waresId = $("input[name=waresId]");
					var waresIdArray = new Array();
					waresId.each(function(index){ 
						waresIdArray[index] = $(this).val();
					});
					var wareCount = $("input[name=wareCount]");
					var wareCountArray = new Array();
					wareCount.each(function(index){ 
						wareCountArray[index] = $(this).val();
					});
					var waresType = $("input[name=waresType]");
					var waresTypeArray = new Array();
					waresType.each(function(index){ 
						waresTypeArray.push($(this).val());
					});
					$.ajax({
						url : "${base}/orderFrontCtl/addBusinessShopCar",
						type : "post",
						data:{
							waresIds : waresIdArray.toString(),
							waresCounts : wareCountArray.toString(),
							waresTypes : waresTypeArray.toString()
						},
						success: function (result) {
							var resultArray = result.split(",");
							jAlert("购物车共有" + resultArray[0] + "件商品，合计：￥" + resultArray[1] + "温馨提示");
						}
					});
					
				});
			});
		</script>
	</head>
	
	<body>
		<div class="main">
			<%@ include file="/common/header.jsp" %>
		    <div class="taocan">
		    	<h2>专为早餐会、集体活动等提供的早餐方案，简单、方便、安全的早餐，按时送到！（<span>70元</span>起送）</h2>
		        <h3>固定套餐</h3>
		        <div class="guding">
		        	<ul>
		            	<li>${i18n == 'en_US' ? fiveCombo.comboenname : fiveCombo.combochname}<span>RMB&nbsp;${fiveCombo.price}元</span></li>
		                <li class="green_01">${i18n == 'en_US' ? tenCombo.comboenname : tenCombo.combochname}<span>RMB&nbsp;${tenCombo.price}元</span></li>
		                <li class="green_02">${i18n == 'en_US' ? fifteenCombo.comboenname : fifteenCombo.combochname}<span>RMB&nbsp;${fifteenCombo.price}元</span></li>
		            </ul>
		        </div>
		        <div class="dinggou">
		       		<div class="taocan_01">
						<p><img src="${base}/images/tu_01.jpg" width="256" height="152" alt="" /></p>
						<ul>
							<c:forEach items="${fiveComboDishList}" var="fiveComboDish">
								<li>
									<img src="${base}/images/icon_01.gif" alt="" />
									${fiveComboDish.dishcount}个${i18n == 'en_US' ? fiveComboDish.dish.dishenname : fiveComboDish.dish.dishchname}
								</li>
							</c:forEach>
							<li>
								<img src="${base}/images/icon_01.gif" alt="" />此套餐订购
								<em><span id="${fiveCombo.comboid}" name="combo" class="numberspinner"></span>份</em>
							</li>
						</ul>
						<p><input type="button" class="btn_dg" value="<spring:message code='ordering' />" onclick="addShopCar(${fiveCombo.comboid})" /></p>
		            </div>
		       		<div class="taocan_02">
						<p><img src="${base}/images/tu_01.jpg" width="256" height="152" alt="" /></p>
						<ul>
							<c:forEach items="${tenComboDishList}" var="tenComboDish">
								<li>
									<img src="${base}/images/icon_01.gif" alt="" />
									${tenComboDish.dishcount}个${i18n == 'en_US' ? tenComboDish.dish.dishenname : tenComboDish.dish.dishchname}
								</li>
							</c:forEach>
							<li>
								<img src="${base}/images/icon_01.gif" alt="" />此套餐订购
								<em><span id="${tenCombo.comboid}" name="combo" class="numberspinner"></span>份</em>
							</li>
						</ul>
						<p><input type="button" class="btn_dg" value="<spring:message code='ordering' />" onclick="addShopCar(${tenCombo.comboid})" /></p>
		            </div>
		       		<div class="taocan_02">
						<p><img src="${base}/images/tu_01.jpg" width="256" height="152" alt="" /></p>
						<ul>
							<c:forEach items="${fifteenComboDishList}" var="fifteenComboDish">
								<li>
									<img src="${base}/images/icon_01.gif" alt="" />
									${fifteenComboDish.dishcount}个${i18n == 'en_US' ? fifteenComboDish.dish.dishenname : fifteenComboDish.dish.dishchname}
								</li>
							</c:forEach>
							<li>
								<img src="${base}/images/icon_01.gif" alt="" />此套餐订购
								<em><span id="${fifteenCombo.comboid}" name="combo" class="numberspinner"></span>份</em>
							</li>
						</ul>
						<p><input type="button" class="btn_dg" value="<spring:message code='ordering' />" onclick="addShopCar(${fifteenCombo.comboid})" /></p>
		            </div>
		       	  <img src="${base}/images/tc_bottom.jpg" alt="" />
		        </div>
		        
		        <h4>自由选择</h4>
		        <div class="dinggou">
		        	<div class="ziyou_01">
		            	<p><img src="${base}/images/tu_02.jpg" width="199" height="140" alt="" /></p>
		                <h5>什锦面包</h5>
						<ul>
							<c:forEach items="${breadList}" var="bread">
								<li>
									<span id="${bread.dishid}" name="dish" class="numberspinner"></span>
									${i18n == 'en_US' ? bread.dishenname : bread.dishchname}(&#65509;${bread.price})
									<input type="hidden" name="waresId" value="${bread.dishid}" />
									<input type="hidden" id="waresCcount${bread.dishid}" value="0" />
									<input type="hidden" id="waresType${bread.dishid}" name="waresType" value="1" />
									<input type="hidden" id="waresPirce${bread.dishid}" name="waresPirce" value="${bread.price}" />
								</li>
		               	  	</c:forEach>
		              </ul>
		          	</div>
		            <div class="ziyou_02">
		            	<p><img src="${base}/images/tu_03.jpg" width="199" height="140" alt="" /></p>
		                <h5>鲜榨果汁</h5>
		                <ul>
							<c:forEach items="${juiceList}" var="juice">
								<li>
									<span id="${juice.dishid}" name="dish" class="numberspinner"></span>
									${i18n == 'en_US' ? juice.dishenname : juice.dishchname}(&#65509;${juice.price})
									<input type="hidden" name="waresId" value="${juice.dishid}" />
									<input type="hidden" id="waresCcount${juice.dishid}" value="0" />
									<input type="hidden" id="waresType${juice.dishid}" name="waresType" value="1" />
									<input type="hidden" id="waresPirce${juice.dishid}" name="waresPirce" value="${juice.price}" />
								</li>
		               	  	</c:forEach>
		              </ul>
		          	</div>
		            <div class="ziyou_02">
		            	<p><img src="${base}/images/tu_04.jpg" width="199" height="140" alt="" /></p>
		                <h5>咖啡、茶</h5>
		                <ul>
							<c:forEach items="${coffeeList}" var="coffee">
								<li>
									<span id="${coffee.dishid}" name="dish" class="numberspinner"></span>
									${i18n == 'en_US' ? coffee.dishenname : coffee.dishchname}(&#65509;${coffee.price})
									<input type="hidden" name="waresId" value="${coffee.dishid}" />
									<input type="hidden" id="waresCcount${coffee.dishid}" value="0" />
									<input type="hidden" id="waresType${coffee.dishid}" name="waresType" value="1" />
									<input type="hidden" id="waresPirce${coffee.dishid}" name="waresPirce" value="${coffee.price}" />
								</li>
		               	  	</c:forEach>
		              </ul>
		          	</div>
		            <div class="ziyou_02">
		            	<p><img src="${base}/images/tu_05.jpg" width="199" height="140" alt="" /></p>
		                <h5>水果沙拉</h5>
		                <ul>
							<c:forEach items="${saladList}" var="salad">
								<li>
									<span id="${salad.dishid}" name="dish" class="numberspinner"></span>
									${i18n == 'en_US' ? salad.dishenname : salad.dishchname}(&#65509;${salad.price})
									<input type="hidden" name="waresId" value="${salad.dishid}" />
									<input type="hidden" id="waresCcount${salad.dishid}" value="0" />
									<input type="hidden" id="waresType${salad.dishid}" name="waresType" value="1" />
									<input type="hidden" id="waresPirce${salad.dishid}" name="waresPirce" value="${salad.price}" />
								</li>
		               	  	</c:forEach>
		              </ul>
		          	</div>
		            <div class="clear"></div>
		            <div class="jiaru">
		            	<p>合计：￥<span id="dishTotalPrice">0</span>元</p>
		                <input id="addShopCarBtn" type="button" class="btn_jr" value="<spring:message code='join' />" />
		            </div>
		        	<img src="${base}/images/tc_bottom.jpg" alt="" />
		        </div>
	    	</div>
                         <%@ include file="/common/footer.jsp" %>
		</div>
               
	</body>
</html>